home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / eigenlib / rg.c < prev   
Encoding:
C/C++ Source or Header  |  1989-11-18  |  2.6 KB  |  74 lines

  1. rg(nm,n,a,wr,wi,matz,z,iv1,fv1)
  2.  
  3. int n,nm,matz;
  4. double **a,*wr,*wi,**z,*fv1;
  5. int *iv1;
  6.  
  7. {
  8.       int is1,is2,ierr;
  9.   
  10. /*    this subroutine calls the recommended sequence of
  11.       subroutines from the eigensystem subroutine package (eispack)
  12.       to find the eigenvalues and eigenvectors (if desired)
  13.       of a real general matrix.
  14.  
  15.       on input
  16.  
  17.          nm  must be set to the row dimension of the two-dimensional
  18.          array parameters as declared in the calling program
  19.          dimension statement.
  20.  
  21.          n  is the order of the matrix  a.
  22.  
  23.          a  contains the real general matrix.
  24.  
  25.          matz  is an integer variable set equal to zero if
  26.          only eigenvalues are desired.  otherwise it is set to
  27.          any non-zero integer for both eigenvalues and eigenvectors.
  28.  
  29.       on output
  30.  
  31.          wr  and  wi  contain the real and imaginary parts,
  32.          respectively, of the eigenvalues.  complex conjugate
  33.          pairs of eigenvalues appear consecutively with the
  34.          eigenvalue having the positive imaginary part first.
  35.  
  36.          z  contains the real and imaginary parts of the eigenvectors
  37.          if matz is not zero.  if the j-th eigenvalue is real, the
  38.          j-th column of  z  contains its eigenvector.  if the j-th
  39.          eigenvalue is complex with positive imaginary part, the
  40.          j-th and (j+1)-th columns of  z  contain the real and
  41.          imaginary parts of its eigenvector.  the conjugate of this
  42.          vector is the eigenvector for the conjugate eigenvalue.
  43.  
  44.          ierr  is an integer output variable set equal to an error
  45.             completion code described in the documentation for hqr
  46.             and hqr2.  the normal completion code is zero.
  47.  
  48.          iv1  and  fv1  are temporary storage arrays.
  49.  
  50.       this routine is a C-translation of the FORTRAN 77 source code
  51.       written by the mathematics and computer science division,
  52.       argonne national laboratory
  53.       last change :   september 1989.
  54.  
  55.       mark myers
  56.       Center for Applied Mathematics 
  57.       Cornell University    (607) 255-4195
  58.  
  59.       --------------------------------------------------------- */
  60.  
  61.       if (n <= nm)   {
  62.          balanc(nm,n,a,&is1,&is2,fv1);
  63.          elmhes(nm,n,&is1,&is2,a,iv1);
  64.          if (matz == 0) 
  65.             ierr=hqr(nm,n,&is1,&is2,a,wr,wi);      /* find eigenvalues only */
  66.          else {
  67.             eltran(nm,n,&is1,&is2,a,iv1,z);        /* find both eigenvalues */
  68.             ierr=hqr2(nm,n,&is1,&is2,a,wr,wi,z);   /* and eigenvectors*/
  69.             if (ierr == 0) balbak(nm,n,&is1,&is2,fv1,n,z);  } }
  70.       else
  71.          ierr = 10 * n; 
  72.       return(ierr);
  73. }
  74.